//
//  YGFoodServerTypeCollectionViewCell.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/24.
//

#import "YGFoodServerTypeCollectionViewCell.h"

@interface YGFoodServerTypeCollectionViewCell ()
@property (nonatomic, strong) UIButton *contentBtn;

@end
@implementation YGFoodServerTypeCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.contentBtn];
        [self.contentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.mas_equalTo(self);
        }];
        
        UIView *leftView = [self lineView];
        [self addSubview:leftView];
        [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.mas_equalTo(self);
            make.width.mas_equalTo(0.5);
        }];
        
        UIView *rightView = [self lineView];
        [self addSubview:rightView];
        [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.bottom.mas_equalTo(self);
            make.width.mas_equalTo(0.5);
        }];
    }
    return self;
}

- (void)configureModel:(YGFoodServerTypeModel *)model{
    [self.contentBtn setTitle:model.name forState:UIControlStateNormal];
    self.contentBtn.selected = model.isSelect;
    if (model.isSelect) {
        self.contentBtn.backgroundColor = UIColorFromRGB(0x37C8D7);
    }else{
        self.contentBtn.backgroundColor = [UIColor whiteColor];
    }
}

- (UIButton *)contentBtn{
    if (!_contentBtn) {
        _contentBtn = [[UIButton alloc] init];
        _contentBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [_contentBtn setTitleColor:UIColorFromRGB(0x3333337) forState:UIControlStateNormal];
        [_contentBtn setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateSelected];
        _contentBtn.userInteractionEnabled = NO;
    }
    return _contentBtn;
}

- (UIView *)lineView{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = UIColorFromRGB(0x37C8D7);
    return view;
}
@end
